import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:h5pay/h5pay.dart';
class H5Jujiji extends StatefulWidget {
  @override
  _H5JujijiState createState() => _H5JujijiState();
}

class _H5JujijiState extends State<H5Jujiji> {
  WebViewController _controller;
//  final PaymentStatus status = await showH5PayDialog(
//  context: context,
//  // You can get payment url (normally is http or payment app scheme) from server in the getPaymentArguments callback
//  getPaymentArguments: () async => PaymentArguments(
//  url: 'https://is.gd/4cLE6j',
//  redirectSchemes: ['alipay', 'alipays', 'weixin', 'wechat'],
//  ),
//  verifyResult: () async => true, // check order result with your server
//  );

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(context, width: 750, height: 1334);
    print(ScreenUtil.statusBarHeight);
    return WebView(
      initialUrl: "https://h5.jujij.com/#/pages/index/index",
      //JS执行模式 是否允许JS执行
      javascriptMode: JavascriptMode.unrestricted,
      onWebViewCreated: (controller) {
        _controller = controller;
      },
      onPageFinished: (url) {
       print('url:${url}');
       if(url.startsWith('https://wx.tenpay.com')){

       }
      },
    );
//  return H5PayWidget(
//    refererScheme: 'https://h5.jujij.com/#/pages/index/index',
//    builder: (ctx, controller) {
//      return FlatButton(
//          onPressed: () {
//            controller.pay('https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=xxx&package=xxx', jumpPayResultCallback: (p) {
//              print("支付跳转结果$p");
//            });
//          },
//          child: Text("立即支付"));
//    },
//  );
//    return WebView(
////      appBar: PreferredSize(
////        preferredSize: Size(750.w,15.w),
////        child: Container(
////          color: Color.fromRGBO(63, 81, 181, 1),
////        ),
////      ),
////      enableAppScheme:true,
////      javascriptMode: JavascriptMode.unrestricted,
//      initialUrl: "https://h5.jujij.com/#/pages/index/index",
////      navigationDelegate: (NavigationRequest request) {
////        print('即将打开'+request.url);
//////        if(request.url.startsWith("weixin://")) {
//////          print("即将打开 ${request.url}");
//////
//////          return NavigationDecision.prevent;
//////        }
//////        return NavigationDecision.navigate;
////      },
////        appBar: new AppBar(
////          title: new Text("Widget webview"),
////        ),
//    );
//    return WebviewScaffold(
//      appBar: PreferredSize(
//        preferredSize: Size(750.w,15.w),
//        child: Container(
//          color: Color.fromRGBO(63, 81, 181, 1),
//        ),
//      ),
//      enableAppScheme:true,
//      url: "https://h5.jujij.com/#/",
////        appBar: new AppBar(
////          title: new Text("Widget webview"),
////        ),
//    );
  }
}
